<?php
 /******************************************************************************
 *   GunCMS is an avid supporter of open source software. This is the appropriate 
 *   option if you are creating an open source application with a license 
 *   compatible with the GNU GPL license v3.
 *   For details http://www.gnu.org/licenses/gpl.html
 *   DO NOT USE FOR COMMERCIAL WITHOUT PERMISSION
 *
 * GunCMS Version 1.0.3
 * Copyright(c) 2009-2010, T & L GdbR
 * info@guncms.de
 * 
 * http://www.guncms.de
 ********************************************************************************/
ob_start();
session_start();

	require_once("../configuration.php");
	require_once("../includes/db/constants.php");
	define(TEMPLATE_NAME,"admin");  ///// set template name to view admin templates 
	require_once("../includes/MySmarty.class.php");
	require("../includes/libraries/fpdf/fpdf.php");
	require("../includes/libraries/fpdf/html2fpdf.php");
	require_once("controller/BgcmsProcess.class.php");
	require_once("mustlogin.php");
	require_once("includes/util.php");
	
	require_once("../model/FgcmsMultiLanguageBean.class.php");
	include_once("../controller/FgcmsMultiLanguage.class.php");
	
	include_once("controller/BgcmsAdminmenu.class.php");
	include_once("controller/BgcmsPaging.class.php");
	include_once("controller/BgcmsPage.class.php");
	include_once("controller/BgcmsCategory.class.php");
	include_once("controller/BgcmsConfigManager.class.php");
	include_once("controller/BgcmsUpload.class.php");
	include_once("controller/BgcmsEmail.class.php");
	include_once("controller/BgcmsMultiLanguage.class.php");
	include_once("includes/plugins/webshop/controller/BWebshopCustomer.class.php");
	include_once("includes/plugins/webshop/controller/BWebshopProduct.class.php");
	include_once("includes/plugins/webshop/controller/BWebshopProductGroup.class.php");
	include_once("includes/plugins/webshop/controller/BWebshopFeaturedProduct.class.php");
	include_once("includes/plugins/webshop/controller/BWebshopSpecialProduct.class.php");
	include_once("includes/plugins/webshop/controller/BWebshopShippingMethod.class.php");
	include_once("includes/plugins/webshop/controller/BWebshopInComingOrder.class.php");
	include_once("includes/plugins/webshop/controller/BWebshopPaymentMethod.class.php");
	include_once("includes/plugins/webshop/controller/BWebshopSettings.class.php");
	
	require_once("model/BgcmsOverviewBean.class.php");
	require_once("model/BgcmsUserBean.class.php");
	require_once("model/BgcmsPageBean.class.php");
	require_once("model/BgcmsCategoryBean.class.php");
	require_once("model/BgcmsProjectBean.class.php");
	include_once("model/BgcmsConfigManagerBean.class.php");
	require_once("model/BgcmsMultiLanguageBean.class.php");
	require_once("model/BgcmsTuLCustomerBean.class.php");
	
	require_once("includes/plugins/webshop/model/BWebshopCustomerBean.class.php");
	include_once("includes/plugins/webshop/model/BWebshopCountryBean.class.php");
	include_once("includes/plugins/webshop/model/BWebshopProductGroupBean.class.php");
	include_once("includes/plugins/webshop/model/BWebshopProductBean.class.php");
	include_once("includes/plugins/webshop/model/BWebshopFeaturedProductBean.class.php");
	include_once("includes/plugins/webshop/model/BWebshopSpecialProductBean.class.php");
	include_once("includes/plugins/webshop/model/BWebshopShippingMethodBean.class.php");
	include_once("includes/plugins/webshop/model/BWebshopInComingOrderBean.class.php");
	include_once("includes/plugins/webshop/model/BWebshopPaymentMethodBean.class.php");
	include_once("includes/plugins/webshop/model/BWebshopEmailReceiverBean.class.php");
	include_once("includes/plugins/webshop/model/BWebshopSettingsBean.class.php");
	
//	/////////////////////////test
//	$fields  = mysql_list_fields($db_database, "tab_user");
//	
//	$columns = mysql_num_fields($fields);
//       
//	for ($i = 0; $i < $columns; $i++) {
//	    $field_array[] = mysql_field_name($fields, $i);
//	}
//	
//	if (!in_array('user_firstname', $field_array)) {
//	    mysql_query("ALTER TABLE `tab_user` ADD `user_firstname` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER `user_name` ;");
//	}
//	if (!in_array('user_lastname', $field_array)) {
//	    mysql_query("ALTER TABLE `tab_user` ADD `user_lastname` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER `user_firstname` ;");
//	}
//	/////////////////////////test
	
	$allmenu = new BgcmsAdminmenu($db, $smarty);
	$allmenu->load_menu_top();
	$str1 = sprintf(_("Welcome %s"), $_SESSION['user_name']);
	$str2 = _("Logout");
	
	$str3 = sprintf("%s <a href='./logout.php' class='link'>%s</a>", $str1, $str2);
	
	$smarty->assign("WELCOME_MSG", $str3);
	
	$option = "";
	if(isset($_GET["module"]))
		$option = $_GET["module"];
	
	if($option=="") {
		$option = "BgcmsOverview";
	}
	
	/**
	 * Show the main content
	 */
	$setbanner =BgcmsOverviewBean::get_system_config($db,'SET_BANNER');
	$smarty->assign("SETBANNER", $setbanner->set);
	$setlang =BgcmsOverviewBean::get_system_config($db,'SET_LANGUAGE');
	$smarty->assign("SETLANG", $setlang->set);
	$setmenu =BgcmsOverviewBean::get_system_config($db,'SET_LEFTMENU');
	$smarty->assign("SETLEFTMENU", $setmenu->set);
	if (file_exists("controller/$option.class.php")) {
		include_once("controller/$option.class.php");
		//we render html depend on parameter
		if($option != "") {
			//we use @ sign to ignore error and do not show any thing
			@($$option = new $option($db, $smarty));
			$$option->process();
		}
	}
		
ob_end_flush();
?>
